package nothing;
import java.util.ArrayList;

import java.util.List;
import java.util.ListIterator;
import org.apache.log4j.Logger;
import nothing.model.Diary;
import nothing.model.Food;

public class DairyResult {
    static Logger log = Logger.getLogger(DairyResult.class);

    public static int OK = 0;
    public static int DATE_CLASH = -1;
    public static int FOOD_MIGHT_GO_OFF = -2;
    private int status = OK;
    private List<Food> offFoods = new ArrayList<Food>();
    private Diary diary = null;
    
    public DairyResult(){
    }
    
    public void setDateClash(Diary diary){
        status = DATE_CLASH;
        this.diary = diary;
    }
    
    public void setOK(){
        status = OK;
    }
    public void setFoodMightGoOff(Food food){
        status = FOOD_MIGHT_GO_OFF;
        offFoods.add(food);
    }
    public List<Food> getOffFoods() {
        return offFoods;
    }
    public boolean isOK(){
        if (status == OK){
                return true;
        }
        return false;
    }
    public boolean isFoodMightGoOff(){
        if (status == FOOD_MIGHT_GO_OFF){
                return true;
        }
        return false;
    }
    public boolean isDateClash(){
        if (status == DATE_CLASH){
                return true;
        }
        return false;
    }
    public String toString(){  
        if (isDateClash()){
            return "This Date is taken with "+diary;
        }
        if (isFoodMightGoOff()){
            StringBuffer sf = new StringBuffer();
            sf.append("The following foods might go off before its cooked");
            for(ListIterator<Food> i =offFoods.listIterator() ; i.hasNext();){
                sf.append(i.next());
            }
            return sf.toString();
        }    
        return "OK";
    }
    
}    
